package com.test.demos.util;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;

/**
 * 返回结果类
 * 
 * @author SunHaoyuan
 */
@Component
public class ResponseUtil {

	public final static int ADD = 1;
	public final static int UPDATE = 2;
	public final static int DELETE = 3;
	public final static int SELECT = 4;


	/**
	 * 获取返回结果Map
	 * 
	 * @param data
	 * @param code
	 * @param msg
	 * @return
	 */
	public static Map<Object,Object> getResponseMap(Object data, CodeEntity code, String msg){
		Map<Object,Object> map = new HashMap<Object, Object>();
		if(code==null){
			code = Code.CODE_500;
		}
		map.put("code", code.getCode());
		map.put("msg",msg);
		map.put("result", code.getResult());
		map.put("data", data);
		return map;
	}



}
